<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/1
 * Time: 9:32
 */
namespace app\admin\validate;

use think\Validate;

class AdminUser extends Validate{
    protected $rule = [
        'username' =>'require',
        'password' => 'require',
        'captcha' => 'require|checkCapcha',
    ];
    protected  $message=[
        'username' =>'用户名不能为空',
        'password' =>'密码不能为空',
        'captcha' =>'验证码不能为空',
    ];

    /**
     * 验证码校验
     * @param $value
     * @param $rule
     * @param array $data
     * @return bool|string
     */
    protected function checkCapcha($value,$rule,$data=[])
    {
        if(!captcha_check($value)){
            return '你输入的验证码不正确！';
        }
        return true;
    }
}